/*******************************************************************************
 * 文件名: DataConfig.java
 * 描    述: 数据配置类(用于数据导入导出)
 * 创建人: Dean Huang(hudi-112@163.com)
 * 日　期: 2017-12-22
 * 描　述: 文件描述
 * 版　本: 1.0
 *******************************************************************************/

package com.z1.core.data;

import java.util.ArrayList;
import java.util.List;

public class DataConfig implements java.io.Serializable {
	
	private static final long serialVersionUID = 4078306770205084036L;
	
	//数据ID
	private String id = null;
	//数据实体BeanName
	private String beanName = null;
	//数据实体Class
	private Class<?> beanClass = null;
	//数据实体字段集合
	private List<DataConfigCell> cells = null;
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public DataConfig id(String id) {
		this.setId(id);
		return this;
	}
	
	public String getBeanName() {
		return beanName;
	}
	public void setBeanName(String beanName) {
		this.beanName = beanName;
	}
	public DataConfig beanName(String beanName) {
		this.setBeanName(beanName);
		return this;
	}
	
	public Class<?> getBeanClass() {
		return beanClass;
	}
	public void setBeanClass(Class<?> beanClass) {
		this.beanClass = beanClass;
	}
	public DataConfig beanClass(Class<?> beanClass) {
		this.setBeanClass(beanClass);
		return this;
	}
	
	public void setCells(List<DataConfigCell> cells) {
		this.cells = cells;
	}
	public void addCell(DataConfigCell cell) {
		if (null == this.cells) {
			this.cells = new ArrayList<DataConfigCell>();
		}
		this.cells.add(cell);
	}
	public DataConfig cells(List<DataConfigCell> cells) {
		this.setCells(cells);
		return this;
	}
	public DataConfig cell(DataConfigCell cell) {
		this.addCell(cell);
		return this;
	}
	
	public List<DataConfigCell> getCells() {
		return cells;
	}
	public String[] getHead() {
		String[] head = new String[cells.size()];
		for (int i = 0; i < cells.size(); i++) {
			head[i] = cells.get(i).getComment();
		}
		return head;
	}
	
	public List<DataConfigCell> getImportCells() {
		List<DataConfigCell> localCells = new ArrayList<DataConfigCell>();
		for (int i = 0; i < cells.size(); i++) {
			if (cells.get(i).isImports()) {
				localCells.add(cells.get(i));
			}
		}
		return localCells;
	}
	public String[] getImportHead() {
		List<String> head = new ArrayList<String>();
		for (int i = 0; i < cells.size(); i++) {
			if (cells.get(i).isImports()) {
				head.add(cells.get(i).getComment());
			}
		}
		return head.toArray(new String[] {});
	}
	
	public List<DataConfigCell> getExportCells() {
		List<DataConfigCell> localCells = new ArrayList<DataConfigCell>();
		for (int i = 0; i < cells.size(); i++) {
			if (cells.get(i).isExport()) {
				localCells.add(cells.get(i));
			}
		}
		return localCells;
	}
	public String[] getExportHead() {
		List<String> head = new ArrayList<String>();
		for (int i = 0; i < cells.size(); i++) {
			if (cells.get(i).isExport()) {
				head.add(cells.get(i).getComment());
			}
		}
		return head.toArray(new String[] {});
	}
	
}
